package project.controllers;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.log4j.Logger;



public class DateFormatter {
	private static final Logger log = Logger.getLogger(DateFormatter.class);
	private ConsoleScanner cs;
	
	public DateFormatter(){
		cs=ConsoleScanner.getInstance();
	}
	
	public GregorianCalendar formatDate(){
		String s=cs.getData();
		SimpleDateFormat f = new SimpleDateFormat("yyyy.MM.dd");
		GregorianCalendar date1 = new GregorianCalendar();
		
		try{
			Date date = f.parse(s);
			date1 = (GregorianCalendar) Calendar.getInstance();
			date1.setTime(date);
			
		}catch(ParseException pe){
			log.error("Parse exception. Wrong date");
			Printer.printMessage(Messager.WRONG_DATE_FORMAT);
		}
		
		return date1;
	}
	
	
	
	public  String getString(){
		String s=cs.getData();
		return s;
	}
	
	

	
}
